<html><head><title>管理页面</title></head><body>
	<?php
		include_once('mysql_connection.php');  //包含连接数据库文件
		//start 检测请求是不是POST，如果是，做登录验证
		if ($_SERVER['REQUEST_METHOD']=='POST') {
			$username_form = $_POST['username_form'];
			$password_form = md5($_POST['password_form']);
			$query = "select * from `admin` where `username`='".$username_form."' and `password`='".$password_form."'";
			$result = $mysql_connection->query($query);
			$num_rows = $result->num_rows;
			if ($num_rows>0) {
			?> 
			<meta http-equiv="Refresh" content="3;URL=guestbook_admin.php">
			<div style="text-align:center;padding:50px;border-style:dashed;border-width:1px;">
				登录成功，系统将自动跳转到管理页面<br /><br />
				<a href="guestbook_admin.php">如果您的浏览器没有自动跳转,请点击这里回到首页</a>
			</div>
			<?php
				setcookie('login', 'true');
			} else {
				echo '用户名或者密码错误，登录失败！';
			}
		}
		//end
		// start 检测是否存在cookie，是否已经录，如果已经登录，页面转向到管理页面
		if (@ $_COOKIE['login']=='true') {
		?> 
		<meta http-equiv="Refresh" content="3;URL=guestbook_admin.php">
		<div style="text-align:center;padding:50px;border-style:dashed;border-width:1px;">
			登录成功，系统将自动跳转到管理页面<br /><br />
			<a href="guestbook_admin.php">如果您的浏览器没有自动跳转,请点击这里回到首页</a>
		</div>
		<?php
			exit;
		}
		// end
	?>
	<!-- start 登录表单 -->
	<div style="text-align:center;"><form action="<?php $_SERVER['PHP_SELF'];?>" method="post">
		<table border="1" align="center">
			<tr><td colspan="2" align="center">登  录</td></tr>
			<tr><td align="center">用户名:</td><td><input type="text" name="username_form" id="username_form" /></td></tr>
			<tr><td align="center">密码:</td><td><input type="password" name="password_form" id="password_form" /></td></tr>
			<tr><td colspan="2" align="center"><input type="submit" value="登     录" /></td></tr>
		<table>
	</form></div>
	<!-- end -->
</body></html>
